<template>
  <div class="notice-card" @click="handleClick">
    <img src="../../../static/menu-ld.png" style="width: 75px;height: 80px" class="c-img"/>
    <!-- 左侧圆点 -->
    <div class="dot"></div>
    <!-- 右侧内容 -->
    <div class="content">
      <!-- 标题 -->
      <div class="title">{{ row.policyTitle }}</div>
      <!-- 日期 -->
      <div class="date">{{ formatDate(row.policyTime || row.createTime) }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'NoticeCard',
  props: {
    row: {
      type: Object,
      required: true,
      default: () => ({})
    }
  },
  methods: {
    formatDate(date) {
      if (!date) return ''
      const [month, day] = date.split('-')
      return `${month}-${day}`
    },
    handleClick() {
      this.$emit('click', this.row)
    }
  }
}
</script>

<style lang="scss" scoped>
.notice-card {
  display: flex;
  align-items: flex-start;
  padding: 16px;
  background-color: $uni-color-success;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  .c-img{
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1;
  }
  &:hover {
    background-color: #e9ecef;
    transform: translateY(-2px);
  }

  // 左侧圆点
  .dot {
    width: 12px;
    height: 12px;
    background-color: $uni-color-primary;
    border-radius: 50%;
    margin-top: 6px;
    margin-right: 16px;
    flex-shrink: 0;
  }

  // 右侧内容
  .content {
    flex: 1;
    z-index: 2;
    // 标题
    .title {
      font-size: 16px;
      line-height: 1.5;
      margin-bottom: 8px;
      font-weight: 500;
      color: $uni-color-primary;
      // 文字超出显示省略号
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
    }

    // 日期
    .date {
      font-size: 14px;
      color: #999;
    }
  }
}
</style>
